import makeRequest from '@/utils/request';

export interface ICourse {
  id: number;
  title: string;
  course_img: string;
  price: string;
  point: string;
  category: string;
}

export type CourseWithoutId = Omit<ICourse, 'id'>;

// 课程获取接口
export const getCourse = async () => {
  return makeRequest<ICourse[]>('/course');
}

// 课程删除接口
export const delCourse = async (data: Partial<CourseWithoutId>) => {
  return makeRequest('/course', {
    data,
    method: 'DELETE'
  });
}

// 课程创建接口
export const createCourse = async (data: CourseWithoutId) => {
  return makeRequest('/course', {
    data,
    method: 'POST',
  });
}

// 课程修改接口
export const updateCourse = async (data: Partial<CourseWithoutId>) => {
  return makeRequest('/course', {
    data,
    method: 'PUT',
  });
}